{__NOLAYOUT__}
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<!--suppress ALL -->
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="favicon.ico" >
    <link rel="Shortcut Icon" href="favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="/static/admin/lib/html5.js"></script>
    <script type="text/javascript" src="/static/admin/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="/static/admin/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="/static/admin/static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/lib/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/lib/icheck/icheck.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script><![endif]-->
    <!--/meta 作为公共模版分离出去-->

    <link href="/static/admin/lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="page-container">
    <form action="{:url('save')}" method="post" class="form form-horizontal" id="form-article-add" enctype="multipart/form-data">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>广告标题：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="请输入广告名称" id="" name="adversts_name">
            </div>
        </div>

        <div class="row cl">
         <label class="form-label col-xs-4 col-sm-2">广告图片：</label>
          <div class="formControls col-xs-8 col-sm-9">
              <div id="upload" class=" btn btn-primary radius">
                      选择图片
              </div>
              图片大小不能超过2M;

              <div class="layui-upload-list">
                  <img class="layui-upload-img" id="demo1" width="200px">
                  <p id="demoText"></p>
              </div>
              <input type="text" value="" name="pic" class="input-text" placeholder="图片保存路径" />         </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>链接地址：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value=""  id="" name="pathinfos" placeholder="如：http://www.baidu.com" />
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>显示位置：</label>
            <div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select class="select" name="sta">
					<option value="1" selected>顶部</option>
					<option value="2">中间</option>
					<option value="3">底部</option>
                    <option value="4">1楼</option>
                    <option value="5">2楼</option>
                    <option value="6">3楼</option>
                    <option value="7">4楼</option>
				</select>
				</span> </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>开始时间：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="layui-input" id="create_time" name="create_time" readonly placeholder="请选择开始时间">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>结束时间：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="layui-input" id="end_time" name="end_time" readonly placeholder="请选择结束时间，不填结束时间为永久有效">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否显示：</label>
            <div class=" skin-minimal formControls col-xs-8 col-sm-9">
                <div class="radio-box">
                    <input type="radio" id="radio-1" name="state" value="0" checked>
                    <label for="radio-1">启用</label>
                </div>
                <div class="radio-box">
                    <input type="radio" id="radio-2" name="state" value="1">
                    <label for="radio-2">禁用</label>
                </div>
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                <button onClick="article_save_submit();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存并提交审核</button>
                <button onClick="article_save();" class="btn btn-secondary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存草稿</button>
                <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
  </div>

                <!--_footer 作为公共模版分离出去-->
                <script type="text/javascript" src="/static/admin/lib/jquery/1.9.1/jquery.min.js"></script><script type="text/javascript" src="/static/admin/lib/layer/2.4/layer.js"></script>
                <script type="text/javascript" src="/static/admin/static/h-ui/js/H-ui.js"></script>
                <script type="text/javascript" src="/static/admin/static/h-ui.admin/js/H-ui.admin.page.js"></script>
                <!--/_footer /作为公共模版分离出去-->

                <!--请在下方写此页面业务相关的脚本-->
                <script type="text/javascript" src="/static/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
                <script type="text/javascript" src="/static/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
                <script type="text/javascript" src="/static/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
                <script type="text/javascript" src="/static/admin/lib/webuploader/0.1.5/webuploader.min.js"></script>
                <script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/ueditor.config.js"></script>
                <script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
                <script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
                <script type="text/javascript" src="/static/admin/lib/layui/layui.js"></script>
                <script type="text/javascript" src="/static/admin/lib/icheck/jquery.icheck.min.js"></script>
<script type="text/javascript">
    $(function() {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        //进行基本的validate的验证
        $("#form-article-add").validate({
            rules:{
                adversts_name:{
                    required:true,
                },
                pic:{
                    required:true,
                },
                state:{
                    required:true,
                },
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form) {
                //进行验证成功后的提交
                $(form).ajaxSubmit({
                    type: 'post',
                    dataType: "json",
                    url: '{:url("doadd")}',
                    success: function (data) {
                        //alert(data.msg);
                        if (data.status == 1){
                            layer.msg(data.msg, {icon: 6,time:1000}, function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.location.reload(); //刷新父页面
                                parent.layer.close(index);
                            });
                        }else{
                            layer.msg(data.msg, {icon: 5});
                        }
                    },
                    error: function (XmlHttpRequest, textStatus, errorThrown) {
                    }
                });
            }
        });

        //进行数据的后台提交
        layui.use(['form','laydate'], function() {
            var form = layui.form;
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#create_time', //指定元素
                type:'datetime'

            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end_time', //指定元素
                type:'datetime'

            });

        });
        //layui的图片上传
        layui.use('upload', function () {
            var upload = layui.upload;
            //执行实例
            var uploadInst = upload.render({
                elem: '#upload' //绑定元素
                , url: '{:url("admin/adversts/pics")}' //上传接口
                , ext: 'jpg|png|gif'
                , area: ['500', '500px']
                , before: function (obj) {
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });
                }
                , done: function (res) {
                    if (res.status == 0) {
                        layer.msg(res.msg, {icon: 2, time: 1000});
                    }
                    $('input[name=pic]').val(res.path);
                    layer.msg(res.msg, {icon: 1, time: 1000});
                }
                , error: function () {
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function () {
                        uploadInst.upload();
                    });
                }
            });
        });
    });
    $(function(){
        var ue = UE.getEditor('editor');
    });
</script>
</body>
</html>